//
//  BLEConstant.h
//  BLESDKDemo
//
//  Created by 李阳 on 2018/4/5.
//  Copyright © 2018年 李阳. All rights reserved.
//

#import <Foundation/Foundation.h>


/// 广播通道类型
typedef NS_ENUM(NSUInteger, BLEAdvertisedChannel)
{
    BLEMediaAdvertisedChannel, ///< 媒体广播通道
    BLEHeartAdvertisedChannel ///< 心率广播通道
};

/// 可写入的通道类型
typedef NS_ENUM(NSUInteger, BLEWritableChannel)
{
    BLEMainWritableChannel, ///< 主要
    BLEMediaWritableChannel, ///< 媒体
    BLENFCWritableChannel, ///< NFC
    BLEPayWritableChannel, ///< 支付
    BLEOTAWritableChannel ///< OTA
};

typedef NSString * const BLENotificationName;

typedef NSString * const BLEConstKey;

typedef Byte const BLEByte;

typedef const Byte * const BLECmd;

FOUNDATION_EXTERN BLEByte kByteBegin;
FOUNDATION_EXTERN BLEByte kByteEnd;
FOUNDATION_EXTERN BLEByte kByteQuery;
FOUNDATION_EXTERN BLECmd kCmdFinish;

FOUNDATION_EXTERN BOOL kBLELogEnable;
FOUNDATION_EXTERN NSTimeInterval const kNoneInterval;

FOUNDATION_EXTERN NSUInteger const kResponseDataStartIndex;
FOUNDATION_EXTERN NSUInteger const kResponseDataEndOffset;

FOUNDATION_EXTERN BLENotificationName BLECenterStateDidChangeNotification;


FOUNDATION_EXTERN void BLEDispatchInMainQueue(void(^block)(void));
FOUNDATION_EXTERN void BLEDispatchInDefaultQueue(void(^block)(void));


#define BLELog(FORMAT, ...) if (kBLELogEnable) {\
static NSDateFormatter *fmt = nil;\
if (!fmt)\
{\
fmt = [[NSDateFormatter alloc]init];\
[fmt setDateFormat:@"HH:mm:ss.SSS"];\
}\
NSString *str = [fmt stringFromDate:[NSDate date]];\
fprintf(stderr,"%s %s\n", [str UTF8String], [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);}

//#ifdef DEBUG
//
//#else
//#define BLELog(FORMAT, ...)
//#endif
